<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/js-test.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script>
description('Tests the behavior of .min and .max of HTMLInputElement.');

var input = document.createElement('input');

// .min and .max just reflect the corresponding attributes.
input.type = 'text';
shouldBe('input.min', '""');
shouldBe('input.max', '""');
input.setAttribute('min', '0');
input.setAttribute('max', '100');
shouldBe('input.min', '"0"');
shouldBe('input.max', '"100"');
input.setAttribute('min', 'abc');
input.setAttribute('max', 'qwerty');
shouldBe('input.min', '"abc"');
shouldBe('input.max', '"qwerty"');

input.min = 'foo';
input.max = 'bar';
shouldBe('input.getAttribute("min")', '"foo"');
shouldBe('input.getAttribute("max")', '"bar"');
input.min = '';
input.max = '';
shouldBe('input.getAttribute("min")', '""');
shouldBe('input.getAttribute("max")', '""');

// Null.
debug('Setting null to min:');
input.min = null;
shouldBe('input.min', '"null"');
shouldBe('input.getAttribute("min")', '"null"');
input.setAttribute('min', null);
shouldBe('input.min', '"null"');

debug('Setting null to max:');
input.max = null;
shouldBe('input.max', '"null"');
shouldBe('input.getAttribute("max")', '"null"');
input.setAttribute('max', null);
shouldBe('input.max', '"null"');

// Undefined.
debug('Setting undefined to min:');
input.min = undefined;
shouldBe('input.min', '"undefined"');
shouldBe('input.getAttribute("min")', '"undefined"');
input.setAttribute('min', undefined);
shouldBe('input.min', '"undefined"');

debug('Setting undefined to max:');
input.max = undefined;
shouldBe('input.max', '"undefined"');
shouldBe('input.getAttribute("max")', '"undefined"');
input.setAttribute('max', undefined);
shouldBe('input.max', '"undefined"');

// Non-string.
debug('Setting non-string to min:');
input.min = 256;
shouldBe('input.min', '"256"');
shouldBe('input.getAttribute("min")', '"256"');
input.setAttribute('min', 256);
shouldBe('input.min', '"256"');

debug('Setting non-string to max:');
input.max = 256;
shouldBe('input.max', '"256"');
shouldBe('input.getAttribute("max")', '"256"');
input.setAttribute('max', 256);
shouldBe('input.max', '"256"');

// The range type has the default minimum and the default maximum.
// But they aren't exposed by .min .max IDL attributes.
debug('Check implicit min/max of type=range:');
input.type = 'range';
input.setAttribute('min', '');
input.setAttribute('max', '');
shouldBe('input.min', '""');
shouldBe('input.max', '""');
</script>
</body>
</html>
